package com.gxnualbert.proxy.reflect;

import java.lang.reflect.InvocationTargetException;

/**
 * @auther gxnualbert
 * @create 2021-05-03-16:12
 */
public class ReflectServiceImpl2 {
    private String name;

    public ReflectServiceImpl2(String name) {
        this.name = name;
    }

    public void sayHello() {
        System.out.println("hello " + name);
    }

    public ReflectServiceImpl2 getInstance() {
        ReflectServiceImpl2 object = null;
        try {
            object = (ReflectServiceImpl2) Class.forName("reflect.ReflectServiceImpl2").getConstructor(String.class).newInstance("陈晖");
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException
                | IllegalArgumentException | InvocationTargetException exception) {
            exception.printStackTrace();
        }
        return object;

    }
}
